<template>
  <div>
    <h1>结算管理</h1>
    <el-form :inline="true" :model="settleAccountsFrom" class="demo-form-inline">
      <el-form-item label="对账批次">
        <el-input v-model="settleAccountsFrom.checkBatchNo" ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="warning" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%"
      @selection-change="handleSelectionChange">
      <el-table-column
        type="selection">
      </el-table-column>
      <el-table-column
        prop="checkBatchNo"
        label="对账批次">
      </el-table-column>
      <el-table-column
        prop="businessName"
        label="商户名称">
      </el-table-column>
      <el-table-column
        prop="amount"
        label="结算金额">
      </el-table-column>
      <el-table-column
        prop="tradeDateZf"
        label="交易日期">
      </el-table-column>
    </el-table>
    <div align="right">
      <el-button type="warning" @click="confirmSettlement">确认结算</el-button>
    </div>
<!--//////////////////////分页/////////////////////////-->

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="settleAccountsFrom.pageNum"
      :page-sizes="[3, 6, 9]"
      :page-size="settleAccountsFrom.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="settleAccountsFrom.total">
    </el-pagination>
  </div>

</template>

<script>
import axios from 'axios'
export default {
  name: "jsgl",
  data() {
    return {
      settleAccountsFrom: {
        checkBatchNo:'',
        pageSize:3,
        pageNum:1,
        total:0,
      },
      tableData: [],
      ids: [],
    }
  },
  methods: {
    confirmSettlement(){
      axios.get('http://localhost:8200/jrfwcwgl/TCwClearingController/settlementManagementDispose?ids='+this.ids).then((response) => {
        if (response.data.code==200){
          alert(JSON.stringify(response.data.msg))
          this.initData();
        }
      })
    },
    handleSelectionChange(val) {
      this.ids=new Array();
      for (let i of val){
        this.ids.push(i.id)
      }
    },
    initData(){
      axios.post('http://localhost:8200/jrfwcwgl/TCwClearingController/settlementManagement', this.settleAccountsFrom).then((response) => {
        console.log(response.data)
        this.tableData = response.data.obj.list
        this.settleAccountsFrom.pageNum = response.data.obj.pageNum
        this.settleAccountsFrom.pageSize = response.data.obj.pageSize
        this.settleAccountsFrom.total = response.data.obj.total
      })
    },
    onSubmit() {
     this.initData();
    },
    handleSizeChange(val) {
      this.settleAccountsFrom.pageSize=val;
      this.initData();
    },
    handleCurrentChange(val) {
      this.settleAccountsFrom.pageNum=val;
      this.initData();
    },
  },
  mounted() {
    this.initData();
  },
}
</script>

<style scoped>

</style>
